package 集合;

import java.util.Objects;

public class Pig {

    private String name;
    private int price;

    public Pig() {
    }

    public Pig(String name, int price) {
        this.name = name;
        this.price = price;
    }

    /**
     * 获取
     * @return name
     */
    public String getName() {
        return name;
    }

    /**
     * 设置
     * @param name
     */
    public void setName(String name) {
        this.name = name;
    }

    /**
     * 获取
     * @return price
     */
    public int getPrice() {
        return price;
    }

    /**
     * 设置
     * @param price
     */
    public void setPrice(int price) {
        this.price = price;
    }

    //覆盖了父类方法
    public String toString() {//Object。。。equals??
        return "toString()>>>Pig{name = " + name + ", price = " + price + "}";
    }

    //getset  altinsert


    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Pig pig = (Pig) o;
        return price == pig.price;
    }

    @Override
    public int hashCode() {
        return Objects.hash(price);
    }
}
